home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / funcs.h < prev    next >
C/C++ Source or Header  |  1993-03-29  |  6KB  |  142 lines

  1. #ifndef FUNCSH
  2. #define FUNCSH
  3.  
  4. /*    Copyright (C) 1993 Free Software Foundation, Inc.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this software; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19. /*  t. lord    Wed Jan 27 15:31:21 1993    */
  20.  
  21.  
  22.  
  23. #include "global.h"
  24.  
  25.  
  26. /*
  27.  * The structure CMD_FUNC describes C functions that can be called
  28.  * interactively. 
  29.  *
  30.  * FUNC_NAME: The name that `execute-function' uses.
  31.  * FUNC_DOC: A `char **' of documentation for the function (NULL terminated).
  32.  * FUNC_ARGS: Similar to an emacs interactive string, however,
  33.  *          rather than a newline separated string, Oleo uses a `char **'.
  34.  * FUNC_FUNC: The C function the implements the command.
  35.  * INIT_CODE: an array of macros or NULL to be executed before editting
  36.  *          begins on an interactive argument.
  37.  *
  38.  *      The syntax of FUNC_ARGS:
  39.  *
  40.  *      In this list, ? stands for an optional arbitrary edit buffer name,
  41.  *      delimited by <>.  For example, to prompt for a file:
  42.  *
  43.  *        "fw<spreadsheets>Save spreadsheet: "
  44.  *
  45.  *     c? - prompt for a single character.
  46.  *         If written c', then the prompt times out after a small
  47.  *         number of seconds, and -1 is passed to the function.
  48.  *         If written c#, then the first character of the prompt string will
  49.  *         be passed to the function and the user will not be prompted.
  50.  *      C? - Command name (or the address of a macro or name of a variable)
  51.  *    d  - Prompt for a double precision floating point number.
  52.  *    fr, fw - Get a file name and pass the opened FILE * to the
  53.  *             function. The file is closed when the function returns.
  54.  *    fn - a file name.
  55.  *    F  - read a cell
  56.  *     k  - read a keysequence (passed as `struct key').
  57.  *     K? - read the name of a keymap
  58.  *      l  - last character typed to invoke this command.
  59.  *    m  - the prompt should be a keymap name.  The user is given
  60.  *         an opertunity to interact using that map as the top-level
  61.  *          map until exit-minibuffer is called.  This generates no
  62.  *          arguments to the function. 
  63.  *         Written m', only one keysequence is read, and that is passed
  64.  *         as a struct keyseq *.
  65.  *      M  - yes or no verify if the buffer has been modified.
  66.  *    N? - Prefix arg as a number, or if none, read from the minibuffer
  67.  *         Input can be constrained to a particular range like this:
  68.  *            "N[1,16]Format number [1-16]: "
  69.  *    n? - like `N', but it always prompts (never uses the prefix).
  70.  *     p  - Prefix arg converted to number.  Does not do I/O.
  71.  *         However, this may be modified by following `p' with:
  72.  *        ? - pass 1 if a prefix arg was explicitly provided, else 0.
  73.  *            r - pass the raw prefix as `struct line *'  (NOT IMPLEMENTED)
  74.  *    r? - Prompt for a range argument (use the mark if it is set).
  75.  *    R? - Prompt for a range argument (don't use the mark, though).
  76.  *    s? - Prompt the user for an arbitrary string.
  77.  *      S? - Any symbol.  If written S', then a NULL char * will be passed
  78.  *         if the user doesn't provide a symbol name.
  79.  *      V  - enter a vi-like navigation state.
  80.  *         In this case, the_cmd_arg.inc_cmd should be set to a hook that
  81.  *         will repeatedly be called with two integer arguments (a direction
  82.  *         and repeat count).  (e.g. imove)
  83.  *    w  - read a word (whitespace delimited).  w' means that the empty
  84.  *         string (normally forbidden) stands for NULL.
  85.  *    #n - N should be an integer.  Pass N (as an int). Does not do I/O.
  86.  *      .  - Return the {mk,}cu{row,col} from the command's frame.
  87.  *         Written .', the mark is ignored, and a one cell range of 
  88.  *         cu{row,col} is returned.
  89.  *    $  - Edit a formula, beginning with the current cells formula as
  90.  *         default.
  91.  *      [  - like c, except that input is constrained to a particular 
  92.  *         character set.  e.g.  "[upd][U]nprotected [P]rotected [D]efault "
  93.  *    =  - pass the (expanded) prompt as a string arument.
  94.  *
  95.  * In addition, if the first character of the first FUNC_ARGS string is a `+'
  96.  * then in expanded macro syntax, the name of the function may be followed
  97.  * by an integer that will be made the value of the prefix argument.  For
  98.  * example:  `{go-right 5}' because the FUNC_ARGS string for go-right is: `+p'.
  99.  */
  100.  
  101.  
  102.  
  103. typedef void (*interactive_function) ();
  104.  
  105. struct cmd_func
  106. {
  107.   char *func_name;
  108.   char ** func_doc;
  109.   char ** func_args;
  110.   char ** init_code;
  111.   interactive_function func_func;
  112. };
  113.  
  114. /*
  115.  * There is a 2d (argv style) array of command functions.  Each 0 dimension
  116.  * slice is called a `vector'.  The first vector contains the oleo built-ins.
  117.  * When looking for a function of a particular name, the array is
  118.  * searched in vector-major order.
  119.  *
  120.  */
  121.  
  122. extern int num_funcs;
  123. extern struct cmd_func **the_funcs;
  124.  
  125. #define find_func(VEC,CMD,NAME) find_function(VEC,CMD,NAME,strlen(NAME))
  126.  
  127. #ifdef __STDC__
  128. extern int find_function (int * vec_out, struct cmd_func ** cmd_out, char * name, int len);
  129. extern void init_named_macro_strings (void);
  130. extern void name_macro_string (char * name, char * str);
  131.  
  132. #else
  133. extern int find_function ();
  134. extern void init_named_macro_strings ();
  135. extern void name_macro_string ();
  136.  
  137. #endif
  138.  
  139. #endif  /* FUNCSH */
  140.  
  141.  
  142.